/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * frmTipoParticipanteXProceso.java
 *
 * Created on 31-may-2011, 22:34:29
 */
package verins.GUI;

import java.awt.Dimension;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.table.DefaultTableModel;
import verins.BO.TUbigeoBO;
import verins.BO.TipoParticipanteXProcesoBO;
import verins.beans.Procesoelectoral;
import verins.beans.Tubigeo;
import verins.beans.Ubigeoxprocesoelectoral;
import verins.beans.UbigeoxprocesoelectoralPK;

/**
 *
 * @author yi
 */
public class frmTipoParticipanteXProceso extends JDialog
{

    private Procesoelectoral procesoElectoral = null;
    List<Tubigeo> lstUbigeo = null;
    List lstProv = null;
    List lstDpto = null;
    List lstDistrito = null;
    private JFrame caller = null;
    private List<Ubigeoxprocesoelectoral> lstUbigeoXProceso = new ArrayList<Ubigeoxprocesoelectoral>();

    /** Creates new form frmTipoParticipanteXProceso */
    public frmTipoParticipanteXProceso(Procesoelectoral proceso, JDialog ventana) {
        super(ventana,true);
        //caller = ventana;
        procesoElectoral = proceso;
        //procesoElectoral = new Procesoelectoral(1);
        //lblCodigoProceso.setText(" prueba");
        initComponents();
        
       // this.setPreferredSize(new Dimension(800, 540));
        llenarCombos();
        if (proceso != null) {
            MostrarDatos(proceso);
            lstUbigeoXProceso=TipoParticipanteXProcesoBO.findAll(proceso);
            llenarTabla();
        }
        this.setSize(new Dimension(900, 580));
        verins.Utils.Comunes.centrarVentana(this);
        btnGuardar.setVisible(false);
    }

    private void llenarCombos() {
        lstUbigeo = TUbigeoBO.findDptoAll();
        lstDpto = obtenerDptos(lstUbigeo);
        verins.Utils.Comunes.llenarCombo(cmbDpto, obtenerDptos(lstUbigeo));
        cmbDpto.insertItemAt((Object) new Tubigeo("00", "Todos"), 0);
        cmbDpto.setSelectedIndex(0);

    }

    private List obtenerDptos(List lista) {
        List lst = new ArrayList();
        Tubigeo ubig = null;
        String codUbigeo = "";
        if (lista != null) {
            Iterator it = lista.iterator();
            while (it.hasNext()) {

                ubig = (Tubigeo) it.next();
                if (ubig.getIdubigeo().contains("0000")) {
                    lst.add(ubig);
                }
            }
        }

        return lst;
    }

    private List obtenerProv(List lista) {
        List lst = new ArrayList();
        if (lista != null) {
            Tubigeo ubig = (Tubigeo) cmbDpto.getSelectedItem();
            String ubigeoDepa = ubig.getIdubigeo();
            String codDepart = ubig.getIdubigeo().substring(0, 2);

            Iterator it = lista.iterator();

            if (!codDepart.equals("00")) {
                while (it.hasNext()) {
                    ubig = (Tubigeo) it.next();
                    // System.out.println(ubig.getIdubigeo());
                    if (ubig.getIdubigeo().substring(0, 2).equals(codDepart)
                            && ubig.getIdubigeo().substring(4).equals("00") && !ubig.getIdubigeo().contains("0000")) {// validar para q slo liste provicinas

                        lst.add(ubig);

                    }
                }
            }
            System.out.println("fin--");
        }
        return lst;
    }

    private List obtenerDist(List lista) {
        List lst = new ArrayList();
        if (lista != null) {
            Tubigeo ubig = (Tubigeo) cmbProvincia.getSelectedItem();
            if (ubig == null) {
                return lst;
            }

            String codProv = ubig.getIdubigeo().substring(0, 4);

            Iterator it = lista.iterator();

            if (!codProv.equals("00")) {
                while (it.hasNext()) {
                    ubig = (Tubigeo) it.next();
                    //SSystem.out.println(ubig.getIdubigeo().substring(0,4));
                    if (ubig.getIdubigeo().substring(0, 4).equals(codProv) && !ubig.getIdubigeo().substring(4).equals("00")) {

                        lst.add(ubig);

                    }
                }
            }
            System.out.println("fin dist");
        }
        return lst;


    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        PanelDatos = new javax.swing.JPanel();
        lblDepartamento = new javax.swing.JLabel();
        lblProvincia = new javax.swing.JLabel();
        cmbDpto = new javax.swing.JComboBox();
        cmbProvincia = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();
        cmbDistrito = new javax.swing.JComboBox();
        btnAsociarProceso = new javax.swing.JButton();
        lblTituloProceso = new javax.swing.JLabel();
        lblCodigoProceso = new javax.swing.JLabel();
        lblNombre = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblUbigeosXProceso = new javax.swing.JTable();
        lblTitulo = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        btnCancelar = new javax.swing.JButton();
        btnGuardar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Ubigeos participantes");
        setResizable(false);

        PanelDatos.setBorder(javax.swing.BorderFactory.createTitledBorder("Ubigeo"));

        lblDepartamento.setText("Departamento");

        lblProvincia.setText("Provincia");

        cmbDpto.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cmbDptoItemStateChanged(evt);
            }
        });

        cmbProvincia.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cmbProvinciaItemStateChanged(evt);
            }
        });

        jLabel1.setText("Distrito");

        btnAsociarProceso.setText("Asociar al Proceso");
        btnAsociarProceso.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAsociarProcesoActionPerformed(evt);
            }
        });

        lblTituloProceso.setText("Código del Proceso Electoral :");

        lblNombre.setText("Proceso Electoral :");

        javax.swing.GroupLayout PanelDatosLayout = new javax.swing.GroupLayout(PanelDatos);
        PanelDatos.setLayout(PanelDatosLayout);
        PanelDatosLayout.setHorizontalGroup(
            PanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PanelDatosLayout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addGroup(PanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(PanelDatosLayout.createSequentialGroup()
                        .addGroup(PanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblDepartamento)
                            .addComponent(cmbDpto, javax.swing.GroupLayout.PREFERRED_SIZE, 259, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(PanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(PanelDatosLayout.createSequentialGroup()
                                .addGap(26, 26, 26)
                                .addComponent(lblCodigoProceso, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(98, 98, 98))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PanelDatosLayout.createSequentialGroup()
                                .addGroup(PanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(cmbProvincia, javax.swing.GroupLayout.PREFERRED_SIZE, 255, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lblProvincia))
                                .addGap(27, 27, 27)
                                .addGroup(PanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel1)
                                    .addGroup(PanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addComponent(btnAsociarProceso)
                                        .addComponent(cmbDistrito, javax.swing.GroupLayout.PREFERRED_SIZE, 237, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGap(87, 87, 87))))
                    .addComponent(lblTituloProceso, javax.swing.GroupLayout.PREFERRED_SIZE, 440, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblNombre, javax.swing.GroupLayout.PREFERRED_SIZE, 696, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        PanelDatosLayout.setVerticalGroup(
            PanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PanelDatosLayout.createSequentialGroup()
                .addComponent(lblNombre)
                .addGap(4, 4, 4)
                .addComponent(lblCodigoProceso)
                .addGap(16, 16, 16)
                .addComponent(lblTituloProceso, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(PanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(PanelDatosLayout.createSequentialGroup()
                        .addComponent(lblDepartamento)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cmbDpto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(PanelDatosLayout.createSequentialGroup()
                        .addGroup(PanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblProvincia)
                            .addComponent(jLabel1))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(PanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(cmbProvincia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cmbDistrito, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btnAsociarProceso)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        tblUbigeosXProceso.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null},
                {null, null},
                {null, null},
                {null, null}
            },
            new String [] {
                "IdUbigeo", "Descripción"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane1.setViewportView(tblUbigeosXProceso);

        lblTitulo.setText("Ubigeos asociados al proceso:");

        btnCancelar.setText("Cancelar");
        btnCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarActionPerformed(evt);
            }
        });

        btnGuardar.setText("Guardar");
        btnGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGuardarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(17, 17, 17)
                        .addComponent(lblTitulo))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(1351, 1351, 1351)
                        .addComponent(jLabel2))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(681, 681, 681)
                        .addComponent(btnGuardar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btnCancelar))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                            .addContainerGap()
                            .addComponent(PanelDatos, 0, 842, Short.MAX_VALUE))
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                            .addGap(12, 12, 12)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 842, Short.MAX_VALUE))))
                .addContainerGap(90, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addComponent(PanelDatos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblTitulo)
                .addGap(18, 18, 18)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 229, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(6, 6, 6)
                .addComponent(jLabel2)
                .addGap(3, 3, 3)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnCancelar)
                    .addComponent(btnGuardar))
                .addContainerGap(26, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed
        // TODO add your handling code here:
        try {
            if (((JButton) evt.getSource()).getText().equalsIgnoreCase("cancelar")) {
                if (verins.Utils.Mensajes.cancelar(evt, this)) {
                    this.dispose();
                }
            } else {//salir
                this.dispose();
            }
        } catch (Exception ex) {
            dispose();
        }



    }//GEN-LAST:event_btnCancelarActionPerformed

    public void llenarTabla() {

        verins.Utils.Comunes.limpiarTabla(tblUbigeosXProceso);

        DefaultTableModel dtm = (DefaultTableModel) tblUbigeosXProceso.getModel();
        if (lstUbigeoXProceso != null && lstUbigeoXProceso.size() > 0) {
            Iterator it = lstUbigeoXProceso.iterator();
            while (it.hasNext()) {
                Ubigeoxprocesoelectoral p = (Ubigeoxprocesoelectoral) it.next();
                Object fila[] = new Object[]{p.getTubigeo().getIdubigeo(), p.getTubigeo().getDescripcion()};
                dtm.addRow(fila);
                System.out.print(p.getTubigeo().getDescripcion());
            }
            verins.Utils.Comunes.setearColumnas(tblUbigeosXProceso);
        }
    }

    private void obtenerDatos() {
        Ubigeoxprocesoelectoral ubigeoPe = null;

        //new UbigeoxprocesoelectoralPK();


        if (lstUbigeo != null) {
           // ubigeoPe = new Ubigeoxprocesoelectoral();
            Tubigeo ubig1 = (Tubigeo) cmbDpto.getSelectedItem();
            Tubigeo ubig2 = (Tubigeo) cmbProvincia.getSelectedItem();
            Tubigeo ubig3 = (Tubigeo) cmbDistrito.getSelectedItem();

           /* System.out.println(" dep " + ubig1.getDescripcion());
            System.out.println(" prov" + ubig2.getDescripcion());
            System.out.println(" distrito" + ubig3.getDescripcion());*/

            if (ubig1.getDescripcion().equalsIgnoreCase("todos") && ubig2.getDescripcion().equalsIgnoreCase("todos") && ubig3.getDescripcion().equalsIgnoreCase("todos")) {

                Iterator it = lstDpto.iterator();
                lstUbigeoXProceso=new ArrayList<Ubigeoxprocesoelectoral>();
                while (it.hasNext()) {
                    ubigeoPe = new Ubigeoxprocesoelectoral();
                    Tubigeo ubig = (Tubigeo) it.next();
                    ubigeoPe.setUbigeoxprocesoelectoralPK(new UbigeoxprocesoelectoralPK(procesoElectoral.getIdprocesoelectoral(), ubig.getIdubigeo()));
                    ubigeoPe.setTubigeo(ubig);
                    lstUbigeoXProceso.add(ubigeoPe);
                    System.out.println(ubigeoPe.getTubigeo().getDescripcion());
                }



            }



            if (!ubig1.getDescripcion().equalsIgnoreCase("todos") && !ubig2.getDescripcion().equalsIgnoreCase("todos") && !ubig3.getDescripcion().equalsIgnoreCase("todos")) {

                ubigeoPe = new Ubigeoxprocesoelectoral();
                ubigeoPe.setUbigeoxprocesoelectoralPK(new UbigeoxprocesoelectoralPK(procesoElectoral.getIdprocesoelectoral(), ubig3.getIdubigeo()));
                ubigeoPe.setTubigeo(ubig3);
                lstUbigeoXProceso.add(ubigeoPe);

            }



            if (!ubig1.getDescripcion().equalsIgnoreCase("todos") && ubig2.getDescripcion().equalsIgnoreCase("todos") && ubig3.getDescripcion().equalsIgnoreCase("todos")) {
                Tubigeo ubig = (Tubigeo) cmbDpto.getSelectedItem();
                String codDepart = ubig.getIdubigeo().substring(0, 2);

                Iterator it = lstUbigeo.iterator();

                lstUbigeoXProceso=new ArrayList<Ubigeoxprocesoelectoral>();
                while (it.hasNext()) {
                    ubig = (Tubigeo) it.next();
                    // System.out.println(ubig.getIdubigeo());
                    if (ubig.getIdubigeo().substring(0, 2).equals(codDepart)) {// validar para q slo liste provicinas


                        ubigeoPe = new Ubigeoxprocesoelectoral();

                        ubigeoPe.setUbigeoxprocesoelectoralPK(new UbigeoxprocesoelectoralPK(procesoElectoral.getIdprocesoelectoral(), ubig.getIdubigeo()));
                        ubigeoPe.setTubigeo(ubig);
                        lstUbigeoXProceso.add(ubigeoPe);
                       // System.out.println(ubigeoPe.getTubigeo().getDescripcion());



                    }
                }



            } // fin




            if (!ubig1.getDescripcion().equalsIgnoreCase("todos") && !ubig2.getDescripcion().equalsIgnoreCase("todos") && ubig3.getDescripcion().equalsIgnoreCase("todos")) {
                //Tubigeo ubig1 = (Tubigeo) cmbDpto.getSelectedItem();
                String codDepart = ubig1.getIdubigeo().substring(0, 2);
                String codPro = ubig2.getIdubigeo().substring(2, 4);

                Iterator it = lstUbigeo.iterator();
                
                 System.out.println(codDepart + " coddepart");
                 System.out.println(codPro + " codPro");
                 lstUbigeoXProceso=new ArrayList<Ubigeoxprocesoelectoral>();
                while (it.hasNext()) {
                   Tubigeo ubig = (Tubigeo) it.next();
                    
                    // System.out.println(ubig.getIdubigeo());
                    if (ubig .getIdubigeo().substring(0, 2).equals(codDepart) && ubig .getIdubigeo().substring(2, 4).equals(codPro) ) {// validar para q slo liste provicinas


                        ubigeoPe = new Ubigeoxprocesoelectoral();
                       
                        ubigeoPe.setUbigeoxprocesoelectoralPK(new UbigeoxprocesoelectoralPK(procesoElectoral.getIdprocesoelectoral(), ubig.getIdubigeo()));
                        ubigeoPe.setTubigeo(ubig);
                        lstUbigeoXProceso.add(ubigeoPe);
                        System.out.println(ubigeoPe.getTubigeo().getDescripcion());
                       


                    }
                }



            }





        }







    }

    private void MostrarDatos(Procesoelectoral proceso) {

       // lblCodigoProceso.setText(proceso.getIdprocesoelectoral() + " ");
        lblTituloProceso.setText(lblTituloProceso.getText()+" "+proceso.getIdprocesoelectoral());
        
        lblNombre.setText(lblNombre.getText()+ " " + proceso.getNombre().toUpperCase());
        System.out.println(proceso.getNombre());
    }

    private void btnAsociarProcesoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAsociarProcesoActionPerformed
        // TODO add your handling code here:

        obtenerDatos();
        llenarTabla();
        verins.Utils.Comunes.setearColumnas(tblUbigeosXProceso);
        btnGuardar.setVisible(true);


    }//GEN-LAST:event_btnAsociarProcesoActionPerformed

    private void cmbDptoItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cmbDptoItemStateChanged
        // TODO add your handling code here:
        Tubigeo ubig = (Tubigeo) cmbDpto.getSelectedItem();
        cmbProvincia.removeAllItems();
        if (!ubig.getDescripcion().equalsIgnoreCase("todos") && !ubig.getIdubigeo().equals("00")) {
            //System.out.println("en carga: "+ubig.getIdubigeo());
            lstProv = obtenerProv(lstUbigeo);
            verins.Utils.Comunes.llenarCombo(cmbProvincia, obtenerProv(lstUbigeo));
        }

        cmbProvincia.insertItemAt((Object) new Tubigeo("00", "Todos"), 0);
        cmbProvincia.setSelectedIndex(0);
    }//GEN-LAST:event_cmbDptoItemStateChanged

    private void cmbProvinciaItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cmbProvinciaItemStateChanged
        // TODO add your handling code here:
        Tubigeo ubig = (Tubigeo) cmbProvincia.getSelectedItem();
        cmbDistrito.removeAllItems();
        if (ubig != null) {
            if (!ubig.getDescripcion().equalsIgnoreCase("todos") && !ubig.getIdubigeo().equals("00")) {
                //System.out.println("en carga: "+ubig.getIdubigeo());

                lstDistrito = obtenerDist(lstUbigeo);
                verins.Utils.Comunes.llenarCombo(cmbDistrito, obtenerDist(lstUbigeo));
            }
        }

        cmbDistrito.insertItemAt((Object) new Tubigeo("00", "Todos"), 0);
        cmbDistrito.setSelectedIndex(0);



    }//GEN-LAST:event_cmbProvinciaItemStateChanged

    private void btnGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGuardarActionPerformed
        // TODO add your handling code here:

        if (((JButton) evt.getSource()).getText().equalsIgnoreCase("guardar")) {
            if (verins.Utils.Mensajes.guardar(evt, this)) {

                obtenerDatos();
                if (verins.Utils.Mensajes.exito(TipoParticipanteXProcesoBO.saveAll(lstUbigeoXProceso))) {
                    this.dispose();
                }



            }
        } else {//
        }



    }//GEN-LAST:event_btnGuardarActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new frmTipoParticipanteXProceso(null, null).setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel PanelDatos;
    private javax.swing.JButton btnAsociarProceso;
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnGuardar;
    private javax.swing.JComboBox cmbDistrito;
    private javax.swing.JComboBox cmbDpto;
    private javax.swing.JComboBox cmbProvincia;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel lblCodigoProceso;
    private javax.swing.JLabel lblDepartamento;
    private javax.swing.JLabel lblNombre;
    private javax.swing.JLabel lblProvincia;
    private javax.swing.JLabel lblTitulo;
    private javax.swing.JLabel lblTituloProceso;
    private javax.swing.JTable tblUbigeosXProceso;
    // End of variables declaration//GEN-END:variables
}
